#!/bin/bash
DATE=$(date +%Y%m%d_%H%M)

MYSQL_CMD="mysql -uroot -pqy22players"

if [ $# -lt 1 ]
then
	echo 'please input the game_set_id .. '
	exit
fi

GAME_ID=$1

if [ -d "/home/yt$GAME_ID/code/run" ]
then
	rm -rf /home/yt$GAME_ID/code/run/sharecache/CACHEDATA.PUBLIC.MMAP 

	#drop dabases ---winter
	${MYSQL_CMD} -e"DROP DATABASE game_db_${GAME_ID};"  	2>/dev/null
	${MYSQL_CMD} -e"CREATE DATABASE game_db_${GAME_ID};"  	2>/dev/null
    echo "drop databases succ..."
	
 	#create database && table
    cd /home/yt$GAME_ID/code/run/dbsvrd
    echo "cd /home/yt$GAME_ID/code/run/dbsvrd"
	../../bin/dbsvrd 1
	sleep 20
	#killall ../../bin/dbsvrd
fi
